package com.project.aaos.util;

import com.project.aaos.pojo.ApproLineInfo;

public class WholeToHalfUtil {

    /*
    * 全角转半角
    * */
    public static String convert(String whole){

        if (whole == null ){
            return whole;
        }

        char[] strArray = whole.toCharArray();
        for (int i=0;i<strArray.length;i++){
            int num = strArray[i];
            if (num>=65281 && num<=65374){
                strArray[i] = (char) (num-65248);
            }
            if (num == 12288){
                strArray[i] = ' ';
            }
        }
        String half = new String(strArray);

        return half;
    }

    /*
    * 将类ApproLineInfo中的全角半角统一转换
    * */
    public static ApproLineInfo convertBean(ApproLineInfo approLineInfo){

        approLineInfo.setAddress1(convert(approLineInfo.getAddress1()));
        approLineInfo.setAddress2(convert(approLineInfo.getAddress2()));
        approLineInfo.setAddress3(convert(approLineInfo.getAddress3()));
        approLineInfo.setAddress4(convert(approLineInfo.getAddress4()));

        approLineInfo.setEmployer_add1(convert(approLineInfo.getEmployer_add1()));
        approLineInfo.setEmployer_add2(convert(approLineInfo.getEmployer_add2()));
        approLineInfo.setEmployer_add3(convert(approLineInfo.getEmployer_add3()));
        approLineInfo.setEmployer_add4(convert(approLineInfo.getEmployer_add4()));

        approLineInfo.setReside_add1(convert(approLineInfo.getReside_add1()));
        approLineInfo.setReside_add2(convert(approLineInfo.getReside_add2()));
        approLineInfo.setReside_add3(convert(approLineInfo.getReside_add3()));
        approLineInfo.setReside_add4(convert(approLineInfo.getReside_add4()));

        approLineInfo.setOwner_name(convert(approLineInfo.getOwner_name()));
        approLineInfo.setSalses_name(convert(approLineInfo.getSalses_name()));
        approLineInfo.setReferrer_name(convert(approLineInfo.getReferrer_name()));
        approLineInfo.setCompanyname(convert(approLineInfo.getCompanyname()));
        approLineInfo.setDepartname(convert(approLineInfo.getDepartname()));
        approLineInfo.setImmidediate_name(convert(approLineInfo.getImmidediate_name()));
        approLineInfo.setOther_name(convert(approLineInfo.getOther_name()));

        approLineInfo.setCar_number(convert(approLineInfo.getCar_number()));
        approLineInfo.setCar_brand(convert(approLineInfo.getCar_brand()));
        approLineInfo.setChinese_name(convert(approLineInfo.getChinese_name()));
        approLineInfo.setGiveCardCity(convert(approLineInfo.getGiveCardCity()));
        approLineInfo.setIssuing_authority(convert(approLineInfo.getIssuing_authority()));
        approLineInfo.setPost(convert(approLineInfo.getPost()));

        return approLineInfo;
    }

}
